#include "jqsort.h"
#include "integerarray.h"

int main(int argc, char ** argv) {
  int lg_size = atoi(argv[1]);
  int num_threads = atoi(argv[2]);
  cout << "lg_size = " << lg_size << " num_therads = " << num_threads << endl;

  InitJobQueue(num_threads);
  
  //BusyJob();
  // exit(1);
  // return 0;

  uint64 size = 1 << lg_size;
  //int *a = new int[size];
   IntegerArray a;
   a.Init(size, lg_size);
   // DistributedTouch(a, size * sizeof(int));
  cout << "setting memory " << endl;
  for (uint64 i=0; i<size; i++) a[i] = i * 29348235281ll & (size-1);
  cout << "Set memory" << endl;
  //less<int> l;
  //JQSort<int *, int, less<int> >(a, a+size, &l, G_JQ);
  less<uint64> l;
  JQSort<IntegerArray::iterator, uint64, less<uint64> >
  (a.begin(), a.end(), &l, G_JQ);
  for (uint64 i=0; i<size; i++) CHECK(a[i] == i);
  for (uint64 i=0; i<10; i++) cout << a[i] << endl;

  

  exit(1);
}

